package cn.edu.zjut.medlinebackend.controller;

import cn.edu.zjut.medlinebackend.model.Notification;
import cn.edu.zjut.medlinebackend.service.NotificationService;
import co.elastic.clients.json.JsonpUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/notifications")
public class NotificationController {
    @Resource
    private NotificationService notificationService;
    @GetMapping("/loadNotifications")
    public List<Notification> loadNotifications(String username){
//        System.out.println(notificationService.getNotificationByUsername(username));
        return notificationService.getNotificationByUsername(username);
    }

    @GetMapping("/markAsRead")
    public String markAsRead(Integer notificationid){
        System.out.println(notificationid);
        notificationService.markAsRead(notificationid);
        return "success";
    }

}
